package com.acme.bankapp.domain.bank;

import com.acme.exceptions.NotEnoughFundsException;

public class SavingAccount extends AbstractAccount {

	public SavingAccount(double amount) {
		super(amount);
	}
	
	@Override
	public void deposit(double amount) {
		if(amount >= 0) {
			this.balance += amount;
		} else {
			throw new IllegalArgumentException("amount should be non-negative!");
		}
	}

	@Override
	public void withdraw(double amount) throws NotEnoughFundsException {
		if(amount >= 0) {
			if(this.balance >= amount) {
				this.balance -= amount;
			} else {
				throw new NotEnoughFundsException("Not enough funds!");
			}
		} else {
			throw new IllegalArgumentException("amount should be non-negative!");
		}
	}

	@Override
	public double maximumAmountToWithdraw() {
		return this.balance;
	}

	@Override
	public String getAccountType(Account account) {
		return "SavingAccount";
	}

}
